#!/bin/sh
if [ $# -lt 1 ] 
then 
	echo "Drop a movie file here to convert it to Playhouse format (pml)"
	exit $E_OPTERROR
fi
outfile=$1
if [ $# -lt 2 ] 
then 
	duration=40
else
	duration=$2
fi
"./ffmpeg" -y -i "$1" "${outfile%.*}.mp3"
"./ffmpeg" -y -i "$1" -pix_fmt rgb24 -f rawvideo -s 30x22 "${outfile%.*}.raw"
"./raw2pml" -a "${outfile%.*}.mp3" -d $duration -s "${outfile%.*}.raw" "${outfile%.*}.pml"
rm "${outfile%.*}.raw"